<template>
	<view class="content">
		<view>
			<u-tabs :list="tabList" :is-scroll="false" font-size="28" height="88" bar-width="56" :bar-style="tabActive"
			 active-color="#171919" inactive-color="#666666" :current="current" @change="change"></u-tabs>
		</view>
		<view class="subject">
			<view class="group-card mt20" v-for="(sale,index) in list" :key="index">
				<groupItem :groupData="sale" :refund="true"></groupItem>
				<view class="info flex" v-if="sale.status != 3">
					<u-button class="ml20" shape="circle" plain size="mini" :custom-style="lastBtn" v-if="sale.status != 2">取消申请</u-button>
					<u-button class="ml20" shape="circle" plain size="mini" :custom-style="lastBtn" v-if="sale.status === 2">填写寄件信息</u-button>
					<u-button class="ml20" shape="circle" plain size="mini" v-if="sale.status === 2">寄件信息</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import order from "../../json/order.js"
	import groupItem from "../../components/group/group.vue"
	export default {
		components: {
			groupItem
		},
		data() {
			return {
				list: [],
				current: 1,
				tabList: [{
					name: '处理中'
				}, {
					name: '申请记录'
				}],
				tabActive: {
					background: "#FCB900"
				},
				lastBtn: {
					borderColor: "#F9274A",
					color: "#F71D41"
				}
			}
		},
		methods: {
			change(index) {
				this.current = index;
			},
			setAfterSaleStatus() {
				order.record.map(item => {
					switch (item.status) {
						case 0:
							item.statusText = "等待审核"
							break;
						case 1:
							item.statusText = "等待取件"
							break;
						case 2:
							item.statusText = "等待寄件"
							break;
						case 3:
							item.statusText = "已完成"
							break;
						default:
							break;
					}
				})
			}
		},
		onLoad() {
			this.setAfterSaleStatus();
			this.list = order.record;
		}
	}
</script>

<style scoped>
	.subject {
		padding: 0 20rpx;
	}

	.group-card {
		background: #FFFFFF;
		padding: 20rpx 26rpx 24rpx;
		border-radius: 12rpx;
	}

	.info {
		margin-top: 32rpx;
		justify-content: flex-end;
	}
</style>
